<?php
declare (strict_types = 1);

namespace app\common\customer\model;

use think\Model;
use think\model\concern\SoftDelete;
use util\Format;

class CustomerContact extends Model
{
    protected $table = "tk_member_contact";

    use SoftDelete;
    protected $defaultSoftDelete = 0;
    protected $type = [
    ];

    public function member()
    {
        return $this->belongsTo(Customer::class, "member_id");
    }

    public function getRoleTypeAttr($value, $data) {
        $map = [
            1 => '本人',
            2 => '丈夫',
            3 => '妈妈',
            4 => '爸爸',
            5 => '婆婆',
            6 => '公公',
            7 => '朋友',
            8 => '其他',
        ];
        $index = $data['role'];

        return isset($map[$index]) ? $map[$index] : "";
    }

    public function getTagAttr($value, $data) {
        $map = [
            1 => '手机',
            2 => '微信',
            3 => '座机'
        ];

        $index = $data['contact_type'];
        return isset($map[$index]) ? $map[$index] : "手机号";
    }
}
